from .base import *    # NOQA

# ---------------------------------------------------------------------------------
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'blog',
        'USER': 'python',
        'PASSWORD': '123',
        'HOST': '192.168.3.19',
        'PORT': 3306,
        'CONN_MAX_AGE': 5 * 60,
        'OPTIONS': {
            'charset': 'utf8mb4',
            'use_unicode': True,
        },
    }
}
# ---------------------------------------------------------------------------------
# Django的缓存配置
CACHES = {
    "default": {
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": "redis://192.168.3.19:6379/1",  # 这里设定了本机的redis数据
        "OPTIONS": {
            "CLIENT_CLASS": "django_redis.client.DefaultClient",
            # "CONNECTION_POOL_KWARGS": {"max_connections": 100, 'decode_responses': True},
        }
    }
}

#
# 配置session存储
SESSION_ENGINE = "django.contrib.sessions.backends.cache"
SESSION_CACHE_ALIAS = "default"

# ------------------------------------------------------
# # 设置Django的文件存储类
# DEFAULT_FILE_STORAGE = 'utils.fdfs.storage.FDFSStorage'

# 设置fdfs使用的client.conf文件路径
FDFS_CLIENT_CONF = './utils/fdfs/client.conf'

# 设置fdfs存储服务器上nginx的IP和端口号
FDFS_URL = 'http://192.168.3.19:8889/'

# ---------------------------------------------------------------------------------


# drf 配置
REST_FRAMEWORK = {
    'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema',
}

LOCAL_HOST_BK = '192.168.3.19'
ES_POINT = '9200'
ELASTICSEARCH_DSL = {
    'default': {
        'hosts': LOCAL_HOST_BK + ':' + ES_POINT
    },
}


HAYSTACK_CONNECTIONS = {
    'default': {
            'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
            'PATH': os.path.join(os.path.dirname(__file__), 'whoosh_index'),
    },
}

# 当添加、修改、删除数据时，自动生成索引
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
# 指定搜索结果每页的条数
HAYSTACK_SEARCH_RESULTS_PER_PAGE = 15

# ---------------------------------------------------------------------------------
MDEDITOR_CONFIGS = {
    'default': {
        'width': '100%',
        'height': 500,
        'toolbar': ["undo", "redo", "|",
                    "bold", "del", "italic", "quote", "ucwords", "uppercase", "lowercase", "|",
                    "h1", "h2", "h3", "h5", "h6", "|",
                    "list-ul", "list-ol", "hr", "|",
                    "link", "reference-link", "image", "code", "preformatted-text", "code-block", "table", "datetime",
                    "emoji", "html-entities", "pagebreak", "goto-line", "|",
                    "help", "info",
                    "||", "preview", "watch", "fullscreen"],
        'upload_image_formats': ["jpg", "JPG", "jpeg", "JPEG", "gif", "GIF", "png",
                                 "PNG", "bmp", "BMP", "webp", "WEBP"],
        'image_folder': "markdownx",
        'theme': 'default',  # dark / default
        'preview_theme': 'default',  # dark / default
        'editor_theme': 'default',  # pastel-on-dark / default
        'toolbar_autofixed': True,
        'search_replace': True,
        'emoji': True,
        'tex': True,
        'task_list': False,
        'flow_chart': True,
        'sequence': True,
        'language': 'zh',  # zh / en
        'watch': True,  # Live preview
        'lineWrapping': False,  # lineWrapping
        'lineNumbers': False,  # lineNumbers
        'app_mdeditor_upload_base_path': os.path.join(BASE_DIR, 'themes', THEME, "markdownx"),
    }
}

# ---------------------------------------------------------------------------------

CELERY_TIMEZONE = "Australia/Tasmania"
CELERY_TASK_TRACK_STARTED = True
CELERY_TASK_TIME_LIMIT = 30 * 60


# CELERY_BROKER_URL = 'redis://192.168.3.19:6379/2'  # 设置broker为代理人
# CELERY_IMPORTS = ('send_mail')  # 导入目标任务文件
# CELERY_TIMEZONE = 'Asia/Shanghai'  # 设置时区
# CELERYBEAT_SCHEDULER = 'djcelery.schedulers.DatabaseScheduler'  # 使用了django-celery默认的数据库调度模型,任务执行周期都被存在默认指定的orm数据库中
#
# CELERY_ACCEPT_CONTENT = ['pickle', 'json']
# CELERY_TASK_SERIALIZER = 'pickle'
# CELERY_RESULT_BACKEND = 'zfapple'
# CELERY_RESULT_SERIALIZER = 'pick'

# 计划任务
# CELERY_RESULT_BACKEND = 'djcelery.backends.database:DatabaseBackend'
# CELERY_ENABLE_UTC = False  # 不是用UTC
# CELERY_TASK_RESULT_EXPIRES = 10  # 任务结果的时效时间
#
# from datetime import timedelta
#
# CELERYBEAT_SCHEDULE = {
#
#     u'定时任务': {
#         "task": "send_mail.tell",
#         "schedule": timedelta(seconds=5),
#         "args": (16, 16),
#     },
#
# }

"""
# #celeryconfig.py
# BROKER_URL = 'redis://localhost:6379/8'   #redis的配置，如果是rabbitmq就不是这个配置
# CELERY_RESULT_BACKEND = 'redis://localhost:6379/8'
#
# CELERY_REDIS_MAX_CONNECTIONS = 4
# CELERYD_CONCURRENCY = 4
# BROKER_TRANSPORT_OPTIONS = {'visibility_timeout': 5}  # 5min
#
# CELERY_TASK_SERIALIZER = 'json'
# CELERY_RESULT_SERIALIZER = 'json'
# CELERY_ACCEPT_CONTENT = ['json']  # Ignore other content
# CELERY_TIMEZONE = 'Asia/Shanghai'
# CELERY_ENABLE_UTC = True
"""